package unit;

import java.awt.Component;
import java.util.ArrayList;
import java.util.List;

import util.IntPoint;

import client.Changeable;
import client.Client;
import control.Tick;
import event.AlfaEvent;
import event.AnswerEvent;
import event.UnitEvent;

public abstract class Unit implements Tick, Changeable{
	protected List<String> moveAbilities;
	private int id;
	protected IntPoint position;
	private boolean hasEvent;
	private AlfaEvent event;
	
	public Unit(int id, IntPoint startpoint){
		this.id = id;
		this.position = startpoint;
		moveAbilities = new ArrayList<String>();
	}
	
	public abstract void tick();
	
	public abstract void sendUpdate(Client client);
	
	public List<String> getMoveabilities() {
		return moveAbilities;
	}

	public IntPoint getPos() {
		return position.clone();
	}
	
	public int id() {
		return id;
	}
	
	public abstract void fireEvent(AlfaEvent e);

	public boolean hasMoved() {
		return true;
	}

	protected void setEvent(AlfaEvent e) {
		event = e;
		hasEvent=true;
	}
	public boolean hasEvent(int i) {
		if (event.toID() == i) {
			return hasEvent;
		} else {
			return false;
		}
	}

	public AlfaEvent getEvent() {
		if(hasEvent){
			hasEvent=false;
			return event;
		}
		System.out.println("Event does not exist. //Unit");
		return null;
	}
}
